<?

/***************************************************************************
 Jupiter Content System @ Jupiterportal.com
 Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/

switch($a)
{
	//-----------------------------------------------------------------
	//  Send Email
	//-----------------------------------------------------------------
	
	case 1:
	
		//-----------------------------------------------------------------
		//  Do Some Checks
		//-----------------------------------------------------------------
		
		if(!$_POST['email']) { header("location: $PHP_SELF?n=modules/contact-us&i=12"); exit; }
		if(!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $_POST['email'])) { header("location: $PHP_SELF?n=modules/contact-us&i=13"); exit; }
		if(!$_POST['name']) { header("location: $PHP_SELF?n=modules/contact-us&i=7"); exit; }
		if(!$_POST['subject']) { header("location: $PHP_SELF?n=modules/contact-us&i=50"); exit; }
		if(!$_POST['message']) { header("location: $PHP_SELF?n=modules/contact-us&i=51"); exit; }
		
		//-----------------------------------------------------------------
		//  Strip Tags
		//-----------------------------------------------------------------
		
		$email = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['email']))));		
		$name = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['name']))));		
		$subject = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['subject']))));		
		$message = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['message']))));		
		
		//-----------------------------------------------------------------
		//  Send Email
		//-----------------------------------------------------------------
		
		$recipient = $config['webmaster_email']; 
		$header = "From: ". $name . " <" . $email . ">\r\n"; 
		mail($recipient, $subject, $message, $header);
		
		//-----------------------------------------------------------------
		//  Redirect User
		//-----------------------------------------------------------------
		
		header("location: $PHP_SELF?n=modules/contact-us&i=53"); exit;
	
	break;
	
	//-----------------------------------------------------------------
	//  Show Form
	//-----------------------------------------------------------------
	
	default:
	?>
		<table class='main' cellpadding='4' cellspacing='1'><tr class='con1'><td><?= $language['Contact Title'] ?></td></tr></table>
		
		<table><tr><td></td></tr></table>
		
		<form method='post' action='<?= $PHP_SELF ?>?n=modules/contact-us&a=1'>
		<table class='main' cellpadding='4' cellspacing='1'>
		<col width='30%'><col width='70%'>
		<tr class='head'><td colspan='2'><?= $language['Contact Title'] ?></td></tr>
		<tr class='bottom'><td colspan='2'><?= $language['Contact Desc1'] ?></td></tr>
		<tr class='con1'><td><span style='color:green;'><?= $language['Contact Desc2'] ?></span><td><input type='text' id='email' name='email' class='box' style='width: 100%;' onload='focus();' /></td></tr>
		<tr class='con1'><td><span style='color:green;'><?= $language['Contact Desc3'] ?></span><td><input type='text' name='name' class='box' style='width: 100%;' /></td></tr>
		<tr class='bottom'><td colspan='2'><?= $language['Contact Desc4'] ?></td></tr>
		<tr class='con1'><td><span style='color:green;'><?= $language['Contact Desc5'] ?></span><td><input type='text' name='subject' class='box' style='width: 100%;' /></td></tr>
		<tr class='con1'><td valign='top'><span style='color:green;'><?= $language['Contact Desc6'] ?></span><td><textarea name='message' rows='5' class='box' style='width: 100%;'></textarea></td></tr>
		<tr class='con1'><td colspan='2' align='right'><input type='submit' name='submit' value='<?= $language['Contact Desc7'] ?>' class='box' /></td></tr>
		</table>
		</form>
	<?
	break;
}
?>